package com.example.program.model

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class sharedViewModel : ViewModel() {
    val number: LiveData<Int> = MutableLiveData(5)

    fun addOne() {
        val mutableNumber = number as MutableLiveData
        //主线程中使用
        mutableNumber.value = mutableNumber.value?.plus(1)
    }
}